//
//  ESGreatTopicVC.m
//  Eyeshot
//
//  Created by admin on 15/7/1.
//  Copyright (c) 2015年 eyeshot. All rights reserved.
//

#import "ESGreatTopicVC.h"
#import "ESDuanziVC.h"
#import "ESDuanziCell.h"
#import "ESDuanziVC.h"
#import "ESPhotoCell.h"
#import "ESPhotoTableViewController.h"
#import "ESVideoCell.h"
#import "ESAllTableViewController.h"
#import "ESAllCell.h"
@interface ESGreatTopicVC ()

@end

@implementation ESGreatTopicVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.collectionView registerClass:[ESPhotoCell class] forCellWithReuseIdentifier:@"photoCell"];
    [self.collectionView registerClass:[ESVideoCell class] forCellWithReuseIdentifier:@"videoCell"];
    [self.collectionView registerClass:[ESDuanziCell class] forCellWithReuseIdentifier:@"duanziCell"];
    [self.collectionView registerClass:[ESPhotoCell class] forCellWithReuseIdentifier:@"greatPhotoCell"];
    [self.collectionView registerClass:[ESAllCell class] forCellWithReuseIdentifier:@"allGreatCell"];
    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"CollectionCell"];
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    switch (indexPath.item) {
   
            
        case 0: {
            ESAllCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"allGreatCell" forIndexPath:indexPath];
            ESAllTableViewController *allCellVC = [[ESAllTableViewController alloc] initWithStyle:UITableViewStylePlain];
            allCellVC.type = @"list";
            cell.allVC = allCellVC;
            cell.backgroundColor = [UIColor redColor];
            [self addChildViewController:allCellVC];
            return cell;
        }
            break;

        case 1: {
            ESVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"videoCell" forIndexPath:indexPath];
            ESVideoVC *videoVc = [[ESVideoVC alloc] initWithStyle:UITableViewStylePlain];
            videoVc.type = @"list";
            cell.videoVC = videoVc;
            [self addChildViewController:videoVc];
            return cell;
        }
            break;
            
        case 2: {
            
            ESPhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"greatPhotoCell" forIndexPath:indexPath];
            
            ESPhotoTableViewController *photoVc = [[ESPhotoTableViewController alloc] initWithStyle:UITableViewStylePlain];
            photoVc.type = @"list";
            cell.photoVC = photoVc;
            [self addChildViewController:photoVc];
            return cell;
            
        }
            break;

        case 3: {
            ESDuanziCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"duanziCell" forIndexPath:indexPath];
            cell.backgroundColor = ESRandomColor;
            ESDuanziVC *duanziVc = [[ESDuanziVC alloc] initWithStyle:UITableViewStylePlain];
            duanziVc.duanziType = @"list";
            cell.tableVc = duanziVc;
            [self addChildViewController:duanziVc];
            return cell;
        }
            break;
        default: {
            UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCell" forIndexPath:indexPath];
            cell.backgroundColor = ESRandomColor;
            return cell;
        }
            break;
    }
    
    
    
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [super scrollViewDidScroll:scrollView];
    CGPoint offset = scrollView.contentOffset;
    
    NSInteger index = offset.x  / SCREEN_WIDTH;
    ESLog(@"%ld",index);
    if (index != 1 || index != 0) {
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"remove" object:nil];
        
    }
}

@end
